using System;
using Scenario.Modules.PCM.DataModel.ConfigurationManager.MetaWorkflow;
using System.Threading;

namespace Scenario.Modules.PCM.DataModel.ConfigurationManager.MetaWorkflow
{
	public class XMLMetaWorkflowsHelper
	{
		static XMLMetaWorkflows xmlMetaWorkflows = null;
		static XMLMetaWorkflows xmlMetaWorkflowsClone = null;

		static Mutex mtx = new Mutex();
		
		public XMLMetaWorkflowsHelper()
		{
		}

		public static XMLMetaWorkflows XMLMetaWorkflows()
		{
			mtx.WaitOne();

			if ( xmlMetaWorkflows == null)
			{
				xmlMetaWorkflows = new XMLMetaWorkflows();
				xmlMetaWorkflows.ReadFromConfiguration();
				xmlMetaWorkflowsClone = xmlMetaWorkflows;
			}

			mtx.ReleaseMutex();
			
			return xmlMetaWorkflowsClone;
		}
	}
}
